home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / bublbobl.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  3KB  |  116 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8. #include "driver.h"
  9. #include "vidhrdw/generic.h"
  10. #include "ctype.h"
  11.  
  12.  
  13.  
  14. unsigned char *bublbobl_objectram;
  15. size_t bublbobl_objectram_size;
  16.  
  17.  
  18.  
  19. void bublbobl_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  20. {
  21.     int i;
  22.  
  23.  
  24.     /* no color PROMs here, only RAM, but the gfx data is inverted so we */
  25.     /* cannot use the default lookup table */
  26.     for (i = 0;i < Machine->drv->color_table_len;i++)
  27.         colortable[i] = i ^ 0x0f;
  28. }
  29.  
  30.  
  31.  
  32. /***************************************************************************
  33.  
  34.   Draw the game screen in the given osd_bitmap.
  35.   Do NOT call osd_update_display() from this function, it will be called by
  36.   the main emulation engine.
  37.  
  38. ***************************************************************************/
  39. void bublbobl_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  40. {
  41.     int offs;
  42.     int sx,sy,xc,yc;
  43.     int gfx_num,gfx_attr,gfx_offs;
  44.  
  45.  
  46.     palette_recalc();
  47.     /* no need to check the return code since we redraw everything each frame */
  48.  
  49.  
  50.     /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
  51.     /* and sprites) are stored in the same memory region, and information on */
  52.     /* the background character columns is stored inthe area dd00-dd3f */
  53.  
  54.     /* This clears & redraws the entire screen each pass */
  55.     fillbitmap(bitmap,Machine->gfx[0]->colortable[0],&Machine->drv->visible_area);
  56.  
  57.     sx = 0;
  58.     for (offs = 0;offs < bublbobl_objectram_size;offs += 4)
  59.     {
  60.         int height;
  61.  
  62.  
  63.         /* skip empty sprites */
  64.         /* this is dword aligned so the UINT32 * cast shouldn't give problems */
  65.         /* on any architecture */
  66.         if (*(UINT32 *)(&bublbobl_objectram[offs]) == 0)
  67.             continue;
  68.  
  69.         gfx_num = bublbobl_objectram[offs + 1];
  70.         gfx_attr = bublbobl_objectram[offs + 3];
  71.  
  72.         if ((gfx_num & 0x80) == 0)    /* 16x16 sprites */
  73.         {
  74.             gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
  75.             height = 2;
  76.         }
  77.         else    /* tilemaps (each sprite is a 16x256 column) */
  78.         {
  79.             gfx_offs = ((gfx_num & 0x3f) * 0x80);
  80.             height = 32;
  81.         }
  82.  
  83.         if ((gfx_num & 0xc0) == 0xc0)    /* next column */
  84.             sx += 16;
  85.         else
  86.         {
  87.             sx = bublbobl_objectram[offs + 2];
  88.             if (gfx_attr & 0x40) sx -= 256;
  89.         }
  90.         sy = 256 - height*8 - (bublbobl_objectram[offs + 0]);
  91.  
  92.         for (xc = 0;xc < 2;xc++)
  93.         {
  94.             for (yc = 0;yc < height;yc++)
  95.             {
  96.                 int goffs,code,color,flipx,flipy,x,y;
  97.  
  98.                 goffs = gfx_offs + xc * 0x40 + yc * 0x02;
  99.                 code = videoram[goffs] + 256 * (videoram[goffs + 1] & 0x03) + 1024 * (gfx_attr & 0x0f);
  100.                 color = (videoram[goffs + 1] & 0x3c) >> 2;
  101.                 flipx = videoram[goffs + 1] & 0x40;
  102.                 flipy = videoram[goffs + 1] & 0x80;
  103.                 x = sx + xc * 8;
  104.                 y = (sy + yc * 8) & 0xff;
  105.  
  106.                 drawgfx(bitmap,Machine->gfx[0],
  107.                         code,
  108.                         color,
  109.                         flipx,flipy,
  110.                         x,y,
  111.                         &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  112.             }
  113.         }
  114.     }
  115. }
  116.